$(function () {
    $('.am-header-title').text('大师门店');
    //addDesignerList(1);
    active();
    //moreDesignerList();
});

function addDesignerList(type){
    var id="#designerList"+type;
    var offset=$(id).attr("offset");
    var rows=$(id).attr("rows");
    //alert(offset);
    var url="/dsmdDesigner/getDsmdDesignerListByType?type="+type+"&offset="+offset+"&rows="+rows;
    $.get(url, function (result) {
        //Handlebar
        var myTemplate = Handlebars.compile($("#dsmd-designer-list").html());
        var id='#designerList'+type;
        $(id).append(myTemplate(result));
        if (result.dsmdDesignerList.length>0){
            $(id).attr("offset",parseInt(offset)+parseInt(rows));
        }
    });

}

function designerDetail(obj){
    var id = $(obj).attr("value");
    var type=$(".am-tabs-nav.am-cf").find(".am-active").val();
    location.href="dsmd-detail.jsp?id="+id+"&type="+type;
}

function moreDesignerList(){
    var type=$(".am-tabs-nav.am-cf").find(".am-active").val();
    //alert(type);
    addDesignerList(type);
}

function active(){
    var active_value=$("#active").val();
    if (active_value == null || active_value == "" || active_value == "null"){
        active_value=1;
    }
    //$(".am-tabs-nav.am-cf").find("li[value="+active_value+"]").attr("class","am-active");
    $(".am-tabs-nav.am-cf").find("a[href='[data-tab-panel-"+active_value+"]']").click();
}